
package com.joysuch.wwyt.bp.enums;

/**
 * 生产装置状态
 *
 */
public enum DeviceFacilityLifecycles {

    PUT_INFO_USE("U", "已投用"), SCRAPED("S", "已报废");

    private String id;
    private String name;

    private DeviceFacilityLifecycles(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public boolean is(String state) {
        return id.equals(state);
    }

    public static DeviceFacilityLifecycles findByName(String name) {
        DeviceFacilityLifecycles[] values = DeviceFacilityLifecycles.values();
        for (DeviceFacilityLifecycles v : values) {
            if (v.getName().equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static DeviceFacilityLifecycles findById(String level) {
        DeviceFacilityLifecycles[] values = DeviceFacilityLifecycles.values();
        for (DeviceFacilityLifecycles v : values) {
            if (v.getId().equals(level)) {
                return v;
            }
        }
        return null;
    }

    public static String findNameById(String id) {
        if (id == null) {
            return null;
        }
        DeviceFacilityLifecycles[] values = DeviceFacilityLifecycles.values();
        for (DeviceFacilityLifecycles v : values) {
            if (v.getId().equals(id)) {
                return v.getName();
            }
        }
        return null;
    }
}
